<?php
/*
Template Name: WorkType template
*/
if($_SERVER['HTTP_X_REQUESTED_WITH']==''):
get_header(); ?>

<div id="accordion">
    <?php include_once (TEMPLATEPATH . '/inc/menu-home.php' ); ?>
	<?php include_once (TEMPLATEPATH . '/inc/menu-news.php' ); ?>
    <div class="panel active hasdata">
		<div class="pink work-menu" rel="pushstate"></div>
		<div class="panelContent p3">
<?php endif; ?>
        <?php include_once (TEMPLATEPATH . '/inc/language-nav.php' ); ?>
		<?php if($_SERVER['HTTP_X_REQUESTED_WITH']==''): ?>
			<div class="container-860 work"><?php endif; ?>			
				<section>
					<h1>WORK</h1>
				<?php
					include_once (TEMPLATEPATH . '/inc/sticky-nav.php' );
				?>	
					<div id="content-data" class="content">
						<?php 	
							global $wp_query;
							$paged 		= isset( $wp_query->query_vars['paged'] ) ? $wp_query->query_vars['paged'] : 1;
							$worktype 	= isset( $wp_query->query_vars["worktype"] ) ? $wp_query->query_vars["worktype"] : "";
							if( $worktype != "" ) {
								$args = array(
									'post_type'				=> 'work',
									'post_status'			=> 'publish',
									'orderby'				=> 'menu_order',
									'posts_per_page'		=> get_option( 'posts_per_page' ),
									'paged'					=> $paged,
									'tax_query' => array(
											array(
												'taxonomy' => 'worktype',
												'field' => 'slug',
												'terms' => $worktype
											)
										)
									);
							}
							else {
								$args = array(
									'post_type'			=> 'work',
									'post_status'		=> 'publish',
									'orderby'			=> 'menu_order',
									'posts_per_page'	=> get_option( 'posts_per_page' ),
									'paged'				=> $paged
									);
							}
							query_posts( $args );

						//--- show work
						if (have_posts()) :
							while (have_posts()) : the_post();
								$subtitle = get_post_meta(get_the_ID(), 'work-subtitle', true); 
						?>
								<div class="thumb">
									<a rel="pushstate-inline" href="<?php the_permalink();?>">   
										<?php the_post_thumbnail('full', array('class'	=> "pc-thumb",)); ?>			
										<div class="thumb-bg">
											<h4><?php the_title();?></h4>
											<h5><?php echo $subtitle; ?></h5>
										</div>
									</a>
								</div>
						<?php 
							endwhile; 
						else : 
							echo "<h2>Nothing found</h2>"; 
						endif; 
						?>
							<h3 class="site">site: Monkey Republic</h3>
					</div>					
				</section>
			</div>
		</div>
		<?php if($_SERVER['HTTP_X_REQUESTED_WITH']==''): ?>
    </div>
    <?php include_once (TEMPLATEPATH . '/inc/menu-contact.php' ); ?>
    <?php include_once (TEMPLATEPATH . '/inc/menu-about.php' ); ?>
</div>
<?php get_footer(); 
	else:
		set_title_header();
	endif;
?>